package com.demo.annotation.controller;

import com.demo.annotation.domain.User;
import com.demo.annotation.utils.ResultResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

/**
 * 需要登录后携带JWT才能访问
 */
@Slf4j
@RestController
public class SecureController {

    /**
     * 查询 用户信息，登录后携带JWT才能访问
     */
    @RequestMapping("/secure/getUserInfo")
    public ResultResponse login(HttpServletRequest request) {
        Integer id = (Integer) request.getAttribute("id");
        User user = new User();
        user.setId(id);
        return ResultResponse.success(user);
    }
}
